package com.baomidou.springwind.test.Set;

import com.baomidou.springwind.test.TextFile;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by Administrator on 2017-01-14.
 */
public class SetWork16 {
    private final static Set<Character> vowels =
            new HashSet<Character>(Arrays.asList('a', 'e', 'o', 'u',
                    'i', 'A', 'E', 'O', 'U', 'I'));
    public static void main(String[] args) {

        Set<String> set = new HashSet<String>();
        new TextFile(
                "F:\\code\\EmployeeManager\\src\\main\\java\\com\\baomidou\\springwind\\test\\Set\\UniqueWords.java",
                "\\W+");
        int fileVowels = 0;
        int wordVowels;
        for (String s : new TextFile(
                "F:\\code\\EmployeeManager\\src\\main\\java\\com\\baomidou\\springwind\\test\\Set\\UniqueWords.java",
                "\\W+")) {
            wordVowels = 0;
            for (char c : s.toCharArray()) {
                if (vowels.contains(c)) {
                    wordVowels++;
                }
                if (!set.contains(s)) {
                    set.add(s);
                    System.out.println(s + " has " + wordVowels + " vowel(s)");
                }
                fileVowels += wordVowels;
            }
            System.out.println("Total number of vowels in file: " + fileVowels);
        }
    }

}
